import BoxInfo from '@/components/box/boxInfo';
import { SvgIcon } from '@/components/icon';
import Modals from '@/components/modals/Modals';
import WorkModule from '@/components/work-modal/work-module';
import { SearchOutlined } from '@ant-design/icons';
import { Button, Input } from 'antd';
import { useState } from 'react';
import orchestrationService from '@/api/services/orchestrationService';

type Props = {
  isShowModel: boolean;
  handleCancel: () => void;
  goToAssistant: (item: any[]) => void;
  fusionApp: any;
};

const FusionappModel = ({ goToAssistant, isShowModel, handleCancel, fusionApp }: Props) => {
  const [showTitle, setShowTitle] = useState('应用列表');

  const [workItems, setWorkItems] = useState([]);

  const confirm = (e: any[]) => {
    setWorkItems(e);
  };

  //获取shareid
  const onGetFusionCollect = async (item: any[]) => {
    const res = await orchestrationService.getAppDetailV2(item[0].app_id, 'public');
    localStorage.setItem('shareId', res.share_id || '');
  };

  const [searchText, setSearchText] = useState('');

  return (
    <Modals
      // footer={null}
      title={showTitle}
      width={1000}
      centered
      open={isShowModel}
      onOk={() => {
        goToAssistant(workItems);
        onGetFusionCollect(workItems);
      }}
      onCancel={handleCancel}
      // footerCancelHidden={true}
      // footerOkHidden={true}
      className="modals-mode"
      okText="确定"
      cancelText="取消"
    >
      {/* <Input
        className="my-[10px] h-[40px] !rounded-default"
        onChange={changeSearchValue}
        value={searchText}
        placeholder="搜索应用"
        prefix={<SearchOutlined className="text-1xl text-gray-400 " />}
      /> */}
      <div className="flex justify-end">
        <Input
          value={searchText}
          onChange={(e) => {
            setSearchText(e.target.value);
          }}
          className="mb-[15px] !rounded-md"
          style={{
            height: '32px',
            width: '200px',
          }}
          placeholder="请输入内容"
          suffix={<SvgIcon icon="work-ic6" size={16} />}
        />
      </div>

      <BoxInfo
        searchText={searchText}
        // appType={'fusion'}
        // appStatus={'unpublished'}
        appType={null}
        paramsType={'public'}
        isMultiSelect={1}
        confirm={confirm}
        selectApps={[{ id: fusionApp }]}
      />
    </Modals>
  );
};

export default FusionappModel;

function setDefaultPage(arg0: (prev: any) => any) {
  throw new Error('Function not implemented.');
}
